<?php
namespace Admin\Controller;
use Think\Controller;
class IndexController extends Controller {

    public function index(){
        $this->display();
    }
    	public function Main()
	{

		G('begin');
	
		$count = [];
		

		$goods = D('goods');
		$gnb = $goods->field('goods_id')->where('goods_number>10')->select();
		$gbest = $goods->field('goods_id')->where('is_best=1')->select();
		$ghot =$goods->field('goods_id')->where('is_hot=1')->select();
		$gsale =$goods->field('goods_id')->where('is_on_sale=1')->select();
		$gnew = $goods->field('goods_id')->where('is_new=1')->select();
		$count['goods'] = [
		'number' => ['count'=>count($gnb),'id'=>array_merge($gnb)],
		'num'    => $goods->count("goods_id"),
		'best'   => ['count'=>count($gbest),'id'=>array_merge($gbest)],
		'hot'    => ['count'=>count($ghot),'id'=>array_merge($ghot)],
		'sale'   => ['count'=>count($gsale),'id'=>array_merge($gsale)],
		'newe'   => ['count'=>count($gnew),'id'=>array_merge($gnew)],
		];

		 $order = D('order');

		$o1 = $order->field('order_id')->where('order_state=1')->select();
		$o2 = $order->field('order_id')->where('order_state=2')->select();
		$o3 = $order->field('order_id')->where('order_state=3')->select();
		$o4 = $order->field('order_id')->where('order_state=4')->select();		
		$o5 = $order->field('order_id')->where('order_state=5')->select(); 
		$o6 = $order->field('order_id')->where('order_tk=1')->select();
		
		$count['order'] = [
		'dq' => ['count'=>count($o1),'id'=>array_merge($o1)], 
		'dz' => ['count'=>count($o2),'id'=>array_merge($o2)], 
		'df' => ['count'=>count($o3),'id'=>array_merge($o3)],
		'wc' => ['count'=>count($o4),'id'=>array_merge($o4)],
		'qh' => ['count'=>count($o5),'id'=>array_merge($o5)],
		'tk' => ['count'=>count($o6),'id'=>array_merge($o6)],
				];
     
    	

		 $info = array(
		'操作系统'=>PHP_OS,
		'运行环境'=>$_SERVER["SERVER_SOFTWARE"],
		'PHP运行方式'=>php_sapi_name(),
		'ThinkPHP版本'=>THINK_VERSION.' [ <a href="http://thinkphp.cn" target="_blank">查看最新版本</a> ]',
		'上传附件限制'=>ini_get('upload_max_filesize'),
		'执行时间限制'=>ini_get('max_execution_time').'秒',
		'服务器时间'=>date("Y年n月j日 H:i:s"),
		'北京时间'=>gmdate("Y年n月j日 H:i:s",time()+8*3600),
		'服务器域名/IP'=>$_SERVER['SERVER_NAME'].' [ '.gethostbyname($_SERVER['SERVER_NAME']).' ]',
		'剩余空间'=>round((disk_free_space(".")/(1024*1024)),2).'M',
		'register_globals'=>get_cfg_var("register_globals")=="1" ? "ON" : "OFF",
		'magic_quotes_gpc'=>(1===get_magic_quotes_gpc())?'YES':'NO',
		'magic_quotes_runtime'=>(1===get_magic_quotes_runtime())?'YES':'NO',
		);
		 $count['footer']=[
    	'cxys' =>G('begin','end'),
    	'nczy'=>G('begin','end','m').'kb'
    	];
		$this->assign('info',$info);
		$this->assign('count',$count);
		$this->display();
	}
}
